package com.asen.business.commons.controller;

import com.asen.business.commons.domain.BaseBill;
import com.asen.business.commons.service.BaseBillService;
import com.asen.commons.constants.BaseConstant;
import com.asen.commons.annotation.Lock;
import com.asen.commons.core.base.result.ApiResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * 基础资料Controller
 *
 * @author Gary
 * @version 1.0
 * @date 2018-12-05
 */
public abstract class AbstractBaseBillController<T extends BaseBill, D, V, S extends BaseBillService<T>> extends AbstractBillController<T, D, V, S> {

    private static final String ENABLE_SUCCESS = "启用成功";

    private static final String DISABLE_SUCCESS = "禁用成功";

    @Lock
    @ApiOperation(value = "启用", httpMethod = BaseConstant.API_POST_METHOD)
    @PostMapping(value = "/enable")
    public ApiResult<String> enable(Long id) throws Exception {
        getService().enable(id);
        return success(ENABLE_SUCCESS);
    }

    @Lock
    @ApiOperation(value = "禁用", httpMethod = BaseConstant.API_POST_METHOD)
    @PostMapping(value = "/disable")
    public ApiResult<String> disable(Long id) throws Exception {
        getService().disable(id);
        return success(DISABLE_SUCCESS);
    }
}
